import java.util.*;


public class Anagram {

	public static boolean isAnagrams(String sentenceA, String sentenceB) {
		String a = sentenceA.replaceAll("\\s", "").toUpperCase();
		String b = sentenceB.replaceAll("\\s", "").toUpperCase();
			
		char[] arrayA = a.toCharArray();
		char[] arrayB = b.toCharArray();
			
		Arrays.sort(arrayA);
		Arrays.sort(arrayB);
			
		return Arrays.equals(arrayA, arrayB);	
	}	
	
	public static void main(String[] args) {
		
		Scanner input = new Scanner(System.in);
		
		String sentenceOne, setnenceTwo;
		
		System.out.print("Enter first sentence: ");
		sentenceOne = input.nextLine();
		
		System.out.print("Enter second sentence: ");
		setnenceTwo = input.nextLine();
		
		System.out.format("The sentences is %sanagrams!" , isAnagrams(sentenceOne, setnenceTwo) ? "" : "not ");
		
	
	}
}